package br.unifor.bd.protocol;

import java.util.List;

public class Transacao {

	private final String id;
	
	private List<Operacao> operacoes;
	
	private Long hora;
	
	public Transacao(String id, List<Operacao> operacoes, Long hora) {
		this.id = id;
		this.operacoes = operacoes;
		this.hora = hora;
	}
	
	public boolean ehAntesDaTransacao(Transacao outraTransacao) {
		return this.hora < outraTransacao.getHora();
	}
	
	public String getId() {
		return id;
	}

	public List<Operacao> getOperacoes() {
		for (Operacao operacao : operacoes) {
			operacao.setTransacao(this);
		}
		
		return operacoes;
	}

	public Long getHora() {
		return hora;
	}
	
	public String toString() {
		return "Transacao " + id;
	}

}
